<?php 
 include_once dirname(__FILE__)."/config.php";
 class ascel_users_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_id;
		 protected $_login;
		 protected $_pwd;
		 protected $_nom;
		 protected $_prenom;
		 protected $_profil;
		 protected $_actif;
		 protected $_date_der_acces;
		 protected $_cin;
		 protected $_tel;
		 protected $_grade;
		 protected $_specialite;
		 protected $_mail;
		 public function get_name_table(){ return "ascel_users";}
		 public function get_name_id(){ return "id";}
		 public function get_name_login(){ return "login";}
		 public function get_name_pwd(){ return "pwd";}
		 public function get_name_nom(){ return "nom";}
		 public function get_name_prenom(){ return "prenom";}
		 public function get_name_profil(){ return "profil";}
		 public function get_name_actif(){ return "actif";}
		 public function get_name_date_der_acces(){ return "date_der_acces";}
		 public function get_name_cin(){ return "cin";}
		 public function get_name_tel(){ return "tel";}
		 public function get_name_grade(){ return "grade";}
		 public function get_name_specialite(){ return "specialite";}
		 public function get_name_mail(){ return "mail";}
		 public function set_id($parametre){  $this->_id=$parametre;}	
		 public function set_login($parametre){  $this->_login=$parametre;}	
		 public function set_pwd($parametre){  $this->_pwd=$parametre;}	
		 public function set_nom($parametre){  $this->_nom=$parametre;}	
		 public function set_prenom($parametre){  $this->_prenom=$parametre;}	
		 public function set_profil($parametre){  $this->_profil=$parametre;}	
		 public function set_actif($parametre){  $this->_actif=$parametre;}	
		 public function set_date_der_acces($parametre){  $this->_date_der_acces=$parametre;}	
		 public function set_cin($parametre){  $this->_cin=$parametre;}	
		 public function set_tel($parametre){  $this->_tel=$parametre;}	
		 public function set_grade($parametre){  $this->_grade=$parametre;}	
		 public function set_specialite($parametre){  $this->_specialite=$parametre;}	
		 public function set_mail($parametre){  $this->_mail=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_id(){ return $this->_id;}
		 public function get_login(){ return $this->_login;}
		 public function get_pwd(){ return $this->_pwd;}
		 public function get_nom(){ return $this->_nom;}
		 public function get_prenom(){ return $this->_prenom;}
		 public function get_profil(){ return $this->_profil;}
		 public function get_actif(){ return $this->_actif;}
		 public function get_date_der_acces(){ return $this->_date_der_acces;}
		 public function get_cin(){ return $this->_cin;}
		 public function get_tel(){ return $this->_tel;}
		 public function get_grade(){ return $this->_grade;}
		 public function get_specialite(){ return $this->_specialite;}
		 public function get_mail(){ return $this->_mail;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 ascel_users(
			login,
			pwd,
			nom,
			prenom,
			profil,
			actif,
			date_der_acces,
			cin,
			tel,
			grade,
			specialite,
			mail)
 VALUES(
			'".$this->_login."',
			'".$this->_pwd."',
			'".$this->_nom."',
			'".$this->_prenom."',
			'".$this->_profil."',
			'".$this->_actif."',
			'".$this->_date_der_acces."',
			'".$this->_cin."',
			'".$this->_tel."',
			'".$this->_grade."',
			'".$this->_specialite."',
			'".$this->_mail."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_login)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
login='".$this->_login."'";
}
if(!empty($this->_pwd)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
pwd='".$this->_pwd."'";
}
if(!empty($this->_nom)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
nom='".$this->_nom."'";
}
if(!empty($this->_prenom)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
prenom='".$this->_prenom."'";
}
if(!empty($this->_profil)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
profil='".$this->_profil."'";
}
if(!empty($this->_actif)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
actif='".$this->_actif."'";
}
if(!empty($this->_date_der_acces)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_der_acces='".$this->_date_der_acces."'";
}
if(!empty($this->_cin)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
cin='".$this->_cin."'";
}
if(!empty($this->_tel)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
tel='".$this->_tel."'";
}
if(!empty($this->_grade)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
grade='".$this->_grade."'";
}
if(!empty($this->_specialite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
specialite='".$this->_specialite."'";
}
if(!empty($this->_mail)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
mail='".$this->_mail."'";
}
$sql="UPDATE 
ascel_users SET 
 ".$sql."
								WHERE id ='".$this->_id."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
ascel_users 
 
									WHERE id ='".$this->_id."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
ascel_users ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		id,
		login,
		pwd,
		nom,
		prenom,
		profil,
		actif,
		date_der_acces,
		cin,
		tel,
		grade,
		specialite,
		mail
 FROM 
 ascel_users";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_id=$row->id;
		$this->_login=$row->login;
		$this->_pwd=$row->pwd;
		$this->_nom=$row->nom;
		$this->_prenom=$row->prenom;
		$this->_profil=$row->profil;
		$this->_actif=$row->actif;
		$this->_date_der_acces=$row->date_der_acces;
		$this->_cin=$row->cin;
		$this->_tel=$row->tel;
		$this->_grade=$row->grade;
		$this->_specialite=$row->specialite;
		$this->_mail=$row->mail;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>